from plant import app, logger
from plant.service.signInServer import SignInServerSV

if __name__ == "__main__":
    from gevent import pywsgi
    from geventwebsocket.handler import WebSocketHandler

    try:
        logger.info("reg to server")
        SignInServerSV().login()
    except:
        logger.error("reg to server failed")

    try:
        logger.info("start flask")
        server = pywsgi.WSGIServer(('0.0.0.0', 5000), app, handler_class=WebSocketHandler)
        server.serve_forever()
    except:
        logger.error('flask start failed')
